<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * 薪资计算条件数据表
 *
 * Date: 2018/6/7
 * @author George
 */
class CreateConditionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('conditions', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('company_id')->index()->comment('公司ID');
			$table->unsignedInteger('pattern_id')->index()->comment('方案ID');
			$table->unsignedInteger('template_id')->index()->comment('模板ID');
            $table->string('type')->comment('条件所属类型');
            $table->string('operator_one', 2)->comment('操作符一');
			$table->decimal('reference_one', 8, 2)->default(0.00)->comment('参照值一');
			$table->string('operator_two', 2)->nullable()->comment('操作符二');
			$table->decimal('reference_two', 8, 2)->default(0.00)->comment('参照值二');
            $table->string('value')->comment('条件值');
			$table->string('expression')->nullable()->comment('表达式');
			$table->json('literals')->nullable()->comment('字面量');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('conditions');
    }
}
